package com.project.weimi.activity;

import com.project.weimi.R;
import com.project.weimi.fragment.ServiceHelpSortFragment;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

/** 使用帮助 */
public class ServiceHelpActivity extends BaseActivity {

	private String[] sort = { "常见问题", "商城保障", "订单事宜", "物流问题", "社区科普" };
	TextView help_sort_show1, help_sort_show2, help_sort_show3, help_sort_show4, help_sort_show5;
	TextView help_sort_show;

	ServiceHelpSortFragment sortFragment = null;
	FragmentManager fragmentManager = null;

	@Override
	protected void onCreate(Bundle arg0) {
		// TODO Auto-generated method stub
		super.onCreate(arg0);
		setContentViewWithBar(R.layout.activity_service_help, "使用帮助");
		bar.getLeftBar().setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});

		help_sort_show = (TextView) this.findViewById(R.id.help_sort_show);
		help_sort_show1 = (TextView) this.findViewById(R.id.help_sort_show1);
		help_sort_show2 = (TextView) this.findViewById(R.id.help_sort_show2);
		help_sort_show3 = (TextView) this.findViewById(R.id.help_sort_show3);
		help_sort_show4 = (TextView) this.findViewById(R.id.help_sort_show4);
		help_sort_show5 = (TextView) this.findViewById(R.id.help_sort_show5);
		help_sort_show1.setOnClickListener(this);
		help_sort_show2.setOnClickListener(this);
		help_sort_show3.setOnClickListener(this);
		help_sort_show4.setOnClickListener(this);
		help_sort_show5.setOnClickListener(this);
		
		fragmentManager = getSupportFragmentManager();
		sortFragment = (ServiceHelpSortFragment) fragmentManager.findFragmentById(R.id.sort_fragment);
		FragmentTransaction ft = fragmentManager.beginTransaction();
		ft.show(sortFragment).commit();
		
		help_sort_show.setText(help_sort_show1.getText().toString());
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.help_sort_show1:
			help_sort_show.setText(help_sort_show1.getText().toString());

			help_sort_show1.setBackgroundColor(getResources().getColor(R.color.help_gridview_checked));
			help_sort_show2.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show3.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show4.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show5.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			break;
		case R.id.help_sort_show2:
			help_sort_show.setText(help_sort_show2.getText().toString());

			help_sort_show1.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show2.setBackgroundColor(getResources().getColor(R.color.help_gridview_checked));
			help_sort_show3.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show4.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show5.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			break;
		case R.id.help_sort_show3:
			help_sort_show.setText(help_sort_show3.getText().toString());

			help_sort_show1.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show2.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show3.setBackgroundColor(getResources().getColor(R.color.help_gridview_checked));
			help_sort_show4.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show5.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			break;
		case R.id.help_sort_show4:
			help_sort_show.setText(help_sort_show4.getText().toString());

			help_sort_show1.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show2.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show3.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show4.setBackgroundColor(getResources().getColor(R.color.help_gridview_checked));
			help_sort_show5.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			break;
		case R.id.help_sort_show5:
			help_sort_show.setText(help_sort_show5.getText().toString());

			help_sort_show1.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show2.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show3.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show4.setBackgroundColor(getResources().getColor(R.color.help_gridview));
			help_sort_show5.setBackgroundColor(getResources().getColor(R.color.help_gridview_checked));
			break;
		}
	}

	@Override
	void setStatusBar(int statusBarColorRes) {
		super.setStatusBar(R.color.transparent_3);
	}
}
